package com.eastmoney.emis.edda.domain.service.edda;

import com.eastmoney.emis.utils.common.sensitive.JsonSensitive;
import com.eastmoney.emis.utils.common.sensitive.JsonSerialize;
import com.eastmoney.emis.utils.common.sensitive.SensitiveType;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotEmpty;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.domain.service
 * @author: 汪程程
 * @date: 2022/9/30 10:58 AM
 * @version: 1.0
 */
@JsonSerialize(include = true)
public class EddaBindCommand {

    @NotEmpty
    private String clientId;
    @NotEmpty
    private String creditorReference;
    @NotEmpty
    private String customEngName;
    @NotEmpty
    private String bankCode;
    @NotEmpty
    private String bankAccount;
    @JsonSensitive(SensitiveType.PHONE)
    private String mobile;
    private String language = "eng";
    @JsonSensitive(SensitiveType.ID_CARD)
    @NotEmpty
    private String debtorPrivateId;
    @NotEmpty
    private String debtorPrivateIdSchemeName;

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getCreditorReference() {
        return creditorReference;
    }

    public void setCreditorReference(String creditorReference) {
        this.creditorReference = creditorReference;
    }

    public String getCustomEngName() {
        return customEngName.trim();
    }

    public void setCustomEngName(String customEngName) {
        this.customEngName = customEngName;
    }

    public String getBankCode() {
        return bankCode;
    }

    public void setBankCode(String bankCode) {
        this.bankCode = bankCode;
    }

    public String getBankAccount() {
        return bankAccount.trim();
    }

    public void setBankAccount(String bankAccount) {
        this.bankAccount = bankAccount;
    }

    public String getDebtorPrivateId() {
        return debtorPrivateId.strip();
    }

    public void setDebtorPrivateId(String debtorPrivateId) {
        this.debtorPrivateId = debtorPrivateId;
    }

    public String getDebtorPrivateIdSchemeName() {
        return debtorPrivateIdSchemeName.strip();
    }

    public void setDebtorPrivateIdSchemeName(String debtorPrivateIdSchemeName) {
        this.debtorPrivateIdSchemeName = debtorPrivateIdSchemeName;
    }

    public String getMobile() {
        if (StringUtils.hasText(mobile)) {
            return mobile.strip();
        }
        return null;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        if ("en".equals(language)) {
            this.language = "eng";
        } else {
            this.language = language;
        }

    }

    @Override
    public String toString() {
        return "EddaAuthCommand{" +
                "clientId='" + clientId + '\'' +
                ", creditorReference='" + creditorReference + '\'' +
                ", customEngName='" + customEngName + '\'' +
                ", bankCode='" + bankCode + '\'' +
                ", bankAccount='" + bankAccount + '\'' +
                ", language='" + language + '\'' +
                ", debtorPrivateId='" + debtorPrivateId + '\'' +
                ", debtorPrivateIdSchemeName='" + debtorPrivateIdSchemeName + '\'' +
                '}';
    }

    public boolean isHsbc() {
        return "004".equals(bankCode);
    }
}
